//
//  LLAlertControllerCell.m
//  MarketingApp
//
//  Created by 李叶夫 on 2018/4/3.
//  Copyright © 2018年 李叶夫. All rights reserved.
//

#import "LLAlertControllerCell.h"

@interface LLAlertControllerCell ()

@property (strong, nonatomic) UIButton *action;

@end

@implementation LLAlertControllerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    self.action = [[UIButton alloc] initWithFrame:self.bounds];
    self.action.backgroundColor = [UIColor whiteColor];
    [self.action setBackgroundImage:[UIImage imageNamed:@"btn_status_highlighted2"] forState:UIControlStateHighlighted];
    [self.action setBackgroundImage:[UIImage imageNamed:@"btn_status_disable"] forState:UIControlStateSelected];
    [self.action setTitleColor:MainTextColor forState:UIControlStateNormal];
    [self.action setTitleColor:ThemeColor forState:UIControlStateSelected];
    self.action.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.action addTarget:self action:@selector(selectedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.action];
}

- (void)setY_selected:(BOOL)y_selected
{
    _y_selected = y_selected;
    self.action.selected = y_selected;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.action.frame = self.bounds;
}

- (void)setActionTitle:(NSString *)actionTitle
{
    _actionTitle = actionTitle;
    [self.action setTitle:actionTitle forState:UIControlStateNormal];
}

- (void)setActionImg:(NSString *)actionImg
{
    _actionImg = actionImg;
    [self.action setImage:[UIImage imageNamed:actionImg] forState:UIControlStateNormal];
}

- (void)selectedAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(alertControllerCell:didSelected:)]) {
        [self.delegate alertControllerCell:self didSelected:sender];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
